<?php

class LanguageMenu extends TTemplateControl
{	
	public function onLoad($params)
	{
		parent::onLoad($params);
		$this->setLanguage();
	}
	
	public function changeLanguageButtonClicked($sender, $param)
	{
		$this->Page->getApplication()->Session->add('language', $param->CommandParameter);
		$this->setLanguage();
		$this->Page->response->reload();
	}
	
	public function setLanguage()
	{
		if(!$this->Page->getApplication()->Session->contains('language'))
			$this->Page->getApplication()->Session->add('language', 'en');
			
		$this->Page->getApplication()->getGlobalization()->setCulture(
			$this->Page->getApplication()->Session->itemAt('language')
		);
	}
	
	public function isLanguageSelected($language)
	{
		return $this->Page->getApplication()->getGlobalization()->getCulture() == $language;
	}
}

?>